package com.boot.controller;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

@WebServlet(urlPatterns = "/servlet/test", description = "指令数据发送")
public class TestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
        System.out.println("servlet sstest");
        Enumeration<String> names=  req.getParameterNames();
        Map<String,String> paramMap=new HashMap<>();
        //遍历请求map
        while(names.hasMoreElements()) {
            String name=names.nextElement();
            String value=(String) req.getParameter(name);
            paramMap.put(name, value);
            System.out.println(paramMap);
        }
    }

}
